{% extends "base.html" %}
{% load form_utils %}

{% block title %}{{ title }} - ExamPulse{% endblock %}

<!-- --- CSS 链接代码 --- -->
{% block extra_css %}
    <link rel="stylesheet" href="/static/users/css/student-form.css">
{% endblock %}

{% block content %}



    <div class="container mt-6 student-form-container">
        <!-- 页面标题 -->
        <div class="text-center mb-6">
            <h2 class="student-page-title">{{ title }}</h2>
            <p class="text-muted student-page-desc">
                {% if 'create' in request.path %}
                    请填写学生完整信息，带 <span class="text-macaron-danger">*</span> 为必填项
                {% else %}
                    可修改学生信息，修改后点击保存生效
                {% endif %}
            </p>
        </div>

        <div class="row justify-content-center">
            <div class="col-md-10 col-lg-8 col-xl-7">
                <div class="card student-form-card shadow-sm hover:shadow-md transition-all duration-300 transform hover:-translate-y-1">
                    <div class="card-header student-form-header bg-gradient-to-r from-macaron-primary/5 to-macaron-primary/10">
                        <h5 class="card-title mb-0 student-form-title">
                            <i class="fas fa-user-edit me-2 text-macaron-primary"></i>{{ title }}
                        </h5>
                    </div>
                    <div class="card-body student-form-body">
                        <!-- 【核心修复1】表单 action 属性留空，使其提交到当前页面 -->
                        <form id="studentForm" method="post" novalidate class="student-form">
                            {% csrf_token %}

                            <!-- 1. 登录账号信息（仅添加时显示） -->
                            {% if 'create' in request.path %}
                                <div class="form-section mb-5 p-4 bg-white rounded-xl shadow-sm border border-macaron-border/50">
                                    <h6 class="section-title border-bottom pb-2 mb-3 text-macaron-text">
                                        登录账号信息 <span class="text-macaron-danger">(必填)</span>
                                    </h6>
                                    <div class="row">
                                        <div class="col-md-6 mb-3">
                                            <label for="{{ form.student_username.id_for_label }}"
                                                   class="form-label student-form-label">
                                                <i class="fas fa-user me-1 text-macaron-primary"></i>{{ form.student_username.label }}
                                            </label>
                                            <div class="relative">
                                                {% with field=form.student_username %}
                                                    {% if field.field.widget.attrs.readonly %}
                                                        <input type="{{ field.field.widget.input_type }}"
                                                               name="{{ field.name }}"
                                                               id="{{ field.id_for_label }}"
                                                               class="form-control student-form-input pl-10 pr-4 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all"
                                                               placeholder="用于登录系统，不可重复"
                                                               required
                                                               {% if field.value %}value="{{ field.value }}"{% endif %}>
                                                    {% else %}
                                                        {{ field|add_class:"form-control student-form-input pl-10 pr-4 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all" }}
                                                    {% endif %}
                                                {% endwith %}
                                                <i class="fas fa-user absolute left-3 top-1/2 -translate-y-1/2 text-macaron-text-light"></i>
                                            </div>
                                            {% if form.student_username.help_text %}
                                                <div class="form-text student-form-help mt-1 text-sm">{{ form.student_username.help_text }}</div>
                                            {% endif %}
                                            {% if form.student_username.errors %}
                                                <div class="text-macaron-danger small mt-1 student-form-error">
                                                    {% for error in form.student_username.errors %}
                                                        <i class="fas fa-exclamation-circle me-1"></i>{{ error }}
                                                    {% endfor %}
                                                </div>
                                            {% endif %}
                                        </div>

                                        <div class="col-md-6 mb-3">
                                            <label for="{{ form.student_password.id_for_label }}"
                                                   class="form-label student-form-label">
                                                <i class="fas fa-lock me-1 text-macaron-primary"></i>{{ form.student_password.label }}
                                            </label>
                                            <div class="relative">
                                                {{ form.student_password|add_class:"form-control student-form-input pl-10 pr-4 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all" }}
                                                <i class="fas fa-lock absolute left-3 top-1/2 -translate-y-1/2 text-macaron-text-light"></i>
                                            </div>
                                            {% if form.student_password.help_text %}
                                                <div class="form-text student-form-help mt-1 text-sm">{{ form.student_password.help_text }}</div>
                                            {% endif %}
                                            {% if form.student_password.errors %}
                                                <div class="text-macaron-danger small mt-1 student-form-error">
                                                    {% for error in form.student_password.errors %}
                                                        <i class="fas fa-exclamation-circle me-1"></i>{{ error }}
                                                    {% endfor %}
                                                </div>
                                            {% endif %}
                                        </div>
                                    </div>
                                </div>
                            {% else %}
                                <!-- 编辑页面：显示当前登录用户名（只读） -->
                                <div class="form-section mb-5 p-4 bg-white rounded-xl shadow-sm border border-macaron-border/50">
                                    <h6 class="section-title border-bottom pb-2 mb-3 text-macaron-text">
                                        登录账号信息 <span class="text-muted">(不可修改)</span>
                                    </h6>
                                    <div class="row">
                                        <div class="col-md-6 mb-3">
                                            <label class="form-label student-form-label">
                                                <i class="fas fa-user me-1 text-macaron-primary"></i>学生登录用户名
                                            </label>
                                            <div class="relative">
                                                <input type="text" value="{{ form.instance.user.username }}"
                                                       class="form-control student-form-input pl-10 pr-4 rounded-lg border-macaron-border bg-gray-50"
                                                       readonly>
                                                <!-- 【核心修复】添加隐藏字段传递用户名 -->
                                                <input type="hidden" name="student_username" value="{{ form.instance.user.username }}">
                                                <i class="fas fa-user absolute left-3 top-1/2 -translate-y-1/2 text-macaron-text-light"></i>
                                            </div>
                                            <div class="form-text student-form-help mt-1 text-sm">
                                                用户名一旦创建，不可修改
                                            </div>
                                        </div>
                                        <div class="col-md-6 mb-3">
                                            <label class="form-label student-form-label">
                                                <i class="fas fa-lock me-1 text-macaron-primary"></i>密码信息
                                            </label>
                                            <div class="relative">
                                                <div class="form-control student-form-input pl-10 pr-4 rounded-lg border border-macaron-border bg-gray-50 text-muted">
                                                    密码信息不可在此修改
                                                </div>
                                                <i class="fas fa-key absolute left-3 top-1/2 -translate-y-1/2 text-muted"></i>
                                            </div>
                                            <div class="form-text student-form-help mt-1 text-sm">
                                                如需修改密码，请联系系统管理员
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            {% endif %}

                            <!-- 2. 基本信息 -->
                            <div class="form-section mb-5 p-4 bg-white rounded-xl shadow-sm border border-macaron-border/50">
                                <h6 class="section-title border-bottom pb-2 mb-3 text-macaron-text flex items-center">
                                    <i class="fas fa-id-card me-2 text-macaron-primary"></i>基本信息
                                </h6>
                                <div class="row g-3">
                                    <div class="col-md-6">
                                        <label for="{{ form.name.id_for_label }}" class="form-label student-form-label">
                                            <i class="fas fa-signature me-1 text-macaron-primary"></i>{{ form.name.label }}
                                            <span class="text-macaron-danger">*</span>
                                        </label>
                                        <div class="relative">
                                            {{ form.name|add_class:"form-control student-form-input pl-10 pr-4 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all" }}
                                            <i class="fas fa-signature absolute left-3 top-1/2 -translate-y-1/2 text-macaron-text-light"></i>
                                        </div>
                                        {% if form.name.errors %}
                                            <div class="text-macaron-danger small mt-1 student-form-error">
                                                {% for error in form.name.errors %}
                                                    <i class="fas fa-exclamation-circle me-1"></i>{{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                    </div>

                                    <div class="col-md-6">
                                        <label for="{{ form.attempt_count.id_for_label }}"
                                               class="form-label student-form-label">
                                            <i class="fas fa-battle-net me-1 text-macaron-primary"></i>{{ form.attempt_count.label }}
                                        </label>
                                        <div class="relative">
                                            {{ form.attempt_count|add_class:"form-select student-form-select pl-10 pr-10 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all appearance-none bg-white" }}
                                            <i class="fas fa-battle-net absolute left-3 top-1/2 -translate-y-1/2 text-macaron-text-light"></i>
                                            <i class="fas fa-chevron-down absolute right-3 top-1/2 -translate-y-1/2 text-macaron-text-light pointer-events-none"></i>
                                        </div>
                                    </div>

                                    <div class="col-md-6">
                                        <label for="{{ form.education_background.id_for_label }}"
                                               class="form-label student-form-label">
                                            <i class="fas fa-graduation-cap me-1 text-macaron-primary"></i>{{ form.education_background.label }}
                                        </label>
                                        <div class="relative">
                                            {{ form.education_background|add_class:"form-select student-form-select pl-10 pr-10 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all appearance-none bg-white" }}
                                            <i class="fas fa-graduation-cap absolute left-3 top-1/2 -translate-y-1/2 text-macaron-text-light"></i>
                                            <i class="fas fa-chevron-down absolute right-3 top-1/2 -translate-y-1/2 text-macaron-text-light pointer-events-none"></i>
                                        </div>
                                    </div>

                                    <div class="col-md-6">
                                        <label for="{{ form.postgraduate_status.id_for_label }}"
                                               class="form-label student-form-label">
                                            <i class="fas fa-clipboard-check me-1 text-macaron-primary"></i>{{ form.postgraduate_status.label }}
                                        </label>
                                        <div class="relative">
                                            {{ form.postgraduate_status|add_class:"form-select student-form-select pl-10 pr-10 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all appearance-none bg-white" }}
                                            <i class="fas fa-clipboard-check absolute left-3 top-1/2 -translate-y-1/2 text-macaron-text-light"></i>
                                            <i class="fas fa-chevron-down absolute right-3 top-1/2 -translate-y-1/2 text-macaron-text-light pointer-events-none"></i>
                                        </div>
                                    </div>

                                    <div class="col-md-6">
                                        <label for="{{ form.phone.id_for_label }}"
                                               class="form-label student-form-label">
                                            <i class="fas fa-mobile-alt me-1 text-macaron-primary"></i>{{ form.phone.label }}
                                        </label>
                                        <div class="relative">
                                            {{ form.phone|add_class:"form-control student-form-input pl-10 pr-4 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all" }}
                                            <i class="fas fa-mobile-alt absolute left-3 top-1/2 -translate-y-1/2 text-macaron-text-light"></i>
                                        </div>
                                        {% if form.phone.help_text %}
                                            <div class="form-text student-form-help mt-1 text-sm">{{ form.phone.help_text }}</div>
                                        {% endif %}
                                        {% if form.phone.errors %}
                                            <div class="text-macaron-danger small mt-1 student-form-error">
                                                {% for error in form.phone.errors %}
                                                    <i class="fas fa-exclamation-circle me-1"></i>{{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                    </div>

                                    <div class="col-md-6">
                                        <label for="{{ form.email.id_for_label }}"
                                               class="form-label student-form-label">
                                            <i class="fas fa-envelope me-1 text-macaron-primary"></i>{{ form.email.label }}
                                        </label>
                                        <div class="relative">
                                            {{ form.email|add_class:"form-control student-form-input pl-10 pr-4 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all" }}
                                            <i class="fas fa-envelope absolute left-3 top-1/2 -translate-y-1/2 text-macaron-text-light"></i>
                                        </div>
                                        {% if form.email.help_text %}
                                            <div class="form-text student-form-help mt-1 text-sm">{{ form.email.help_text }}</div>
                                        {% endif %}
                                    </div>

                                    <div class="col-md-6">
                                        <label for="{{ form.undergraduate_school.id_for_label }}"
                                               class="form-label student-form-label">
                                            <i class="fas fa-university me-1 text-macaron-primary"></i>{{ form.undergraduate_school.label }}
                                        </label>
                                        <div class="relative">
                                            {{ form.undergraduate_school|add_class:"form-control student-form-input pl-10 pr-4 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all" }}
                                            <i class="fas fa-university absolute left-3 top-1/2 -translate-y-1/2 text-macaron-text-light"></i>
                                        </div>
                                    </div>

                                    <div class="col-md-6">
                                        <label for="{{ form.undergraduate_major.id_for_label }}"
                                               class="form-label student-form-label">
                                            <i class="fas fa-book-open me-1 text-macaron-primary"></i>{{ form.undergraduate_major.label }}
                                        </label>
                                        <div class="relative">
                                            {{ form.undergraduate_major|add_class:"form-control student-form-input pl-10 pr-4 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all" }}
                                            <i class="fas fa-book-open absolute left-3 top-1/2 -translate-y-1/2 text-macaron-text-light"></i>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <!-- 3. 考研目标 -->
                            <div class="form-section mb-5 p-4 bg-white rounded-xl shadow-sm border border-macaron-border/50">
                                <h6 class="section-title border-bottom pb-2 mb-3 text-macaron-text flex items-center">
                                    <i class="fas fa-bullseye me-2 text-macaron-primary"></i>考研目标
                                </h6>
                                <div class="row g-3">
                                    <div class="col-md-6">
                                        <label for="{{ form.target_school.id_for_label }}"
                                               class="form-label student-form-label">
                                            <i class="fas fa-target me-1 text-macaron-primary"></i>{{ form.target_school.label }}
                                        </label>
                                        <div class="relative">
                                            {{ form.target_school|add_class:"form-control student-form-input pl-10 pr-4 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all" }}
                                            <i class="fas fa-building-columns absolute left-3 top-1/2 -translate-y-1/2 text-macaron-text-light"></i>
                                        </div>
                                    </div>

                                    <div class="col-md-6">
                                        <label for="{{ form.target_major.id_for_label }}"
                                               class="form-label student-form-label">
                                            <i class="fas fa-bullseye me-1 text-macaron-primary"></i>{{ form.target_major.label }}
                                        </label>
                                        <div class="relative">
                                            {{ form.target_major|add_class:"form-control student-form-input pl-10 pr-4 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all" }}
                                            <i class="fas fa-book-bookmark absolute left-3 top-1/2 -translate-y-1/2 text-macaron-text-light"></i>
                                        </div>
                                    </div>

                                    <div class="col-md-6">
                                        <label for="{{ form.target_code.id_for_label }}"
                                               class="form-label student-form-label">
                                            <i class="fas fa-hashtag me-1 text-macaron-primary"></i>{{ form.target_code.label }}
                                        </label>
                                        <div class="relative">
                                            {{ form.target_code|add_class:"form-control student-form-input pl-10 pr-4 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all" }}
                                            <i class="fas fa-hashtag absolute left-3 top-1/2 -translate-y-1/2 text-macaron-text-light"></i>
                                        </div>
                                    </div>

                                    <div class="col-md-6">
                                        <label for="{{ form.exam_type.id_for_label }}"
                                               class="form-label student-form-label">
                                            <i class="fas fa-hashtag me-1 text-macaron-primary"></i>{{ form.exam_type.label }}
                                        </label>
                                        <div class="relative">
                                            {{ form.exam_type|add_class:"form-control student-form-input pl-10 pr-4 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all" }}
                                            <i class="fas fa-hashtag absolute left-3 top-1/2 -translate-y-1/2 text-macaron-text-light"></i>
                                        </div>
                                    </div>

                                </div>
                            </div>

                            <!-- 4. 考试科目 -->
                            <div class="form-section mb-5 p-4 bg-white rounded-xl shadow-sm border border-macaron-border/50">
                                <h6 class="section-title border-bottom pb-2 mb-3 text-macaron-text flex items-center">
                                    <i class="fas fa-pencil-alt me-2 text-macaron-primary"></i>考试科目
                                </h6>
                                <div class="row g-4 align-items-center">
                                    <!-- 政治 -->
                                    <div class="col-12">
                                        <div class="d-flex items-center h-10">
                                            <div class="form-check form-switch student-form-switch">
                                                {{ form.has_politics|add_class:"form-check-input student-form-check w-12 h-6 rounded-full bg-macaron-border checked:bg-macaron-primary transition-all duration-300 focus:ring-macaron-primary/30" }}
                                            </div>
                                            <label class="form-check-label student-form-check-label ms-3 text-macaron-text cursor-pointer"
                                                   for="{{ form.has_politics.id_for_label }}">
                                                <i class="fas fa-vote-yea me-1 text-macaron-primary"></i>{{ form.has_politics.label }}
                                            </label>
                                        </div>
                                    </div>

                                    <!-- 英语：开关 + 下拉框 -->
                                    <div class="col-12">
                                        <div class="row g-3 align-items-center">
                                            <div class="col-md-5">
                                                <div class="d-flex items-center h-10">
                                                    <div class="form-check form-switch student-form-switch">
                                                        {{ form.has_english|add_class:"form-check-input student-form-check w-12 h-6 rounded-full bg-macaron-border checked:bg-macaron-primary transition-all duration-300 focus:ring-macaron-primary/30" }}
                                                    </div>
                                                    <label class="form-check-label student-form-check-label ms-3 text-macaron-text cursor-pointer"
                                                           for="{{ form.has_english.id_for_label }}">
                                                        <i class="fas fa-language me-1 text-macaron-primary"></i>{{ form.has_english.label }}
                                                    </label>
                                                </div>
                                            </div>
                                            <div class="col-md-7">
                                                <label for="{{ form.english_type.id_for_label }}"
                                                       class="form-label student-form-label">
                                                    <i class="fas fa-font me-1 text-macaron-primary"></i>{{ form.english_type.label }}
                                                </label>
                                                <div class="relative">
                                                    {{ form.english_type|add_class:"form-select student-form-select pl-10 pr-10 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all appearance-none bg-white"|attr:"required:false" }}
                                                    <i class="fas fa-font absolute left-3 top-1/2 -translate-y-1/2 text-macaron-text-light"></i>
                                                    <i class="fas fa-chevron-down absolute right-3 top-1/2 -translate-y-1/2 text-macaron-text-light pointer-events-none"></i>
                                                </div>
                                                {% if form.english_type.errors %}
                                                    <div class="text-macaron-danger small mt-1 student-form-error">
                                                        {% for error in form.english_type.errors %}
                                                            <i class="fas fa-exclamation-circle me-1"></i>{{ error }}
                                                        {% endfor %}
                                                    </div>
                                                {% endif %}
                                            </div>
                                        </div>
                                    </div>

                                    <!-- 数学：开关 + 下拉框 -->
                                    <div class="col-12">
                                        <div class="row g-3 align-items-center">
                                            <div class="col-md-5">
                                                <div class="d-flex items-center h-10">
                                                    <div class="form-check form-switch student-form-switch">
                                                        {{ form.has_math|add_class:"form-check-input student-form-check w-12 h-6 rounded-full bg-macaron-border checked:bg-macaron-primary transition-all duration-300 focus:ring-macaron-primary/30" }}
                                                    </div>
                                                    <label class="form-check-label student-form-check-label ms-3 text-macaron-text cursor-pointer"
                                                           for="{{ form.has_math.id_for_label }}">
                                                        <i class="fas fa-calculator me-1 text-macaron-primary"></i>{{ form.has_math.label }}
                                                    </label>
                                                </div>
                                            </div>
                                            <div class="col-md-7">
                                                <label for="{{ form.math_type.id_for_label }}"
                                                       class="form-label student-form-label">
                                                    <i class="fas fa-square-root-alt me-1 text-macaron-primary"></i>{{ form.math_type.label }}
                                                </label>
                                                <div class="relative">
                                                    {{ form.math_type|add_class:"form-select student-form-select pl-10 pr-10 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all appearance-none bg-white"|attr:"required:false" }}
                                                    <i class="fas fa-square-root-alt absolute left-3 top-1/2 -translate-y-1/2 text-macaron-text-light"></i>
                                                    <i class="fas fa-chevron-down absolute right-3 top-1/2 -translate-y-1/2 text-macaron-text-light pointer-events-none"></i>
                                                </div>
                                                {% if form.math_type.errors %}
                                                    <div class="text-macaron-danger small mt-1 student-form-error">
                                                        {% for error in form.math_type.errors %}
                                                            <i class="fas fa-exclamation-circle me-1"></i>{{ error }}
                                                        {% endfor %}
                                                    </div>
                                                {% endif %}
                                            </div>
                                        </div>
                                    </div>

                                    <!-- 专业课：名称 + 代码 -->
                                    <div class="col-12">
                                        <div class="row g-3">
                                            <div class="col-md-6">
                                                <label for="{{ form.professional_subject_name.id_for_label }}"
                                                       class="form-label student-form-label">
                                                    <i class="fas fa-book me-1 text-macaron-primary"></i>{{ form.professional_subject_name.label }}
                                                </label>
                                                <div class="relative">
                                                    {{ form.professional_subject_name|add_class:"form-control student-form-input pl-10 pr-4 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all" }}
                                                    <i class="fas fa-book absolute left-3 top-1/2 -translate-y-1/2 text-macaron-text-light"></i>
                                                </div>
                                                {% if form.professional_subject_name.errors %}
                                                    <div class="text-macaron-danger small mt-1 student-form-error">
                                                        {% for error in form.professional_subject_name.errors %}
                                                            <i class="fas fa-exclamation-circle me-1"></i>{{ error }}
                                                        {% endfor %}
                                                    </div>
                                                {% endif %}
                                            </div>
                                            <div class="col-md-6">
                                                <label for="{{ form.professional_subject_code.id_for_label }}"
                                                       class="form-label student-form-label">
                                                    <i class="fas fa-code me-1 text-macaron-primary"></i>{{ form.professional_subject_code.label }}
                                                </label>
                                                <div class="relative">
                                                    {{ form.professional_subject_code|add_class:"form-control student-form-input pl-10 pr-4 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all" }}
                                                    <i class="fas fa-code absolute left-3 top-1/2 -translate-y-1/2 text-macaron-text-light"></i>
                                                </div>
                                                {% if form.professional_subject_code.errors %}
                                                    <div class="text-macaron-danger small mt-1 student-form-error">
                                                        {% for error in form.professional_subject_code.errors %}
                                                            <i class="fas fa-exclamation-circle me-1"></i>{{ error }}
                                                        {% endfor %}
                                                    </div>
                                                {% endif %}
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <!-- 5. 备注信息 -->
                            <div class="form-section mb-6 p-4 bg-white rounded-xl shadow-sm border border-macaron-border/50">
                                <h6 class="section-title border-bottom pb-2 mb-3 text-macaron-text flex items-center">
                                    <i class="fas fa-comment-dots me-2 text-macaron-primary"></i>备注信息
                                </h6>
                                <div class="row">
                                    <div class="col-md-12">
                                        <label for="{{ form.notes.id_for_label }}"
                                               class="form-label student-form-label">
                                            <i class="fas fa-sticky-note me-1 text-macaron-primary"></i>{{ form.notes.label }}
                                        </label>
                                        <div class="relative">
                                            {{ form.notes|add_class:"form-control student-form-textarea pl-10 pr-4 rounded-lg border-macaron-border focus:border-macaron-primary focus:ring-2 focus:ring-macaron-primary/20 transition-all resize-none"|attr:"rows:3" }}
                                            <i class="fas fa-sticky-note absolute left-3 top-4 text-macaron-text-light"></i>
                                        </div>
                                        {% if form.notes.help_text %}
                                            <div class="form-text student-form-help mt-1 text-sm">{{ form.notes.help_text }}</div>
                                        {% endif %}
                                        {% if form.notes.errors %}
                                            <div class="text-macaron-danger small mt-1 student-form-error">
                                                {% for error in form.notes.errors %}
                                                    <i class="fas fa-exclamation-circle me-1"></i>{{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                    </div>
                                </div>
                            </div>

                            <!-- 按钮区域 -->
                            <div class="form-actions d-flex flex-wrap gap-3 justify-content-end mt-8">
                                <!-- 【核心修复3】确保返回列表链接的 URL 语法正确 -->
                                <a href="{% url 'users:student_list' %}"
                                   class="btn btn-macaron-secondary px-6 py-2.5 rounded-lg transition-all duration-300 hover:bg-macaron-secondary-dark flex items-center">
                                    <i class="fas fa-arrow-left me-2"></i>返回列表
                                </a>
                                <button type="reset"
                                        class="btn btn-macaron-outline-secondary px-6 py-2.5 rounded-lg border border-macaron-border transition-all duration-300 hover:bg-macaron-outline-secondary flex items-center">
                                    <i class="fas fa-redo me-2"></i>重置
                                </button>
                                <button type="submit"
                                        class="btn btn-macaron-primary px-6 py-2.5 rounded-lg transition-all duration-300 hover:bg-macaron-primary-dark hover:shadow-lg hover:shadow-macaron-primary/20 flex items-center"
                                        id="submitBtn">
                                    <i class="fas fa-save me-2"></i>保存信息
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}

<!-- --- JS 链接代码 --- -->
{% block extra_js %}
    <script src="/static/users/js/student-form.js"></script>
{% endblock %}